using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using SideShow.Events;

namespace SideShow.Scf.Events
{
    [Serializable]
    public class ScfMenuActionEvent : ScfNavigationEvent
    {
        private uint _itemId;

        public ScfMenuActionEvent()
        {
        }

        public ScfMenuActionEvent(Guid applicationId, Guid endpointId, uint previousPage, uint targetPage, ScfButton button, uint itemId)
            : base(applicationId, endpointId, (int) SideShowEvents.SCF_EVENT_IDS.SCF_EVENT_MENUACTION, previousPage, targetPage, button)
        {
            _itemId = itemId;
        }

        public uint ItemId
        {
            get { return _itemId; }
        }

        protected override int EventDataSize
        {
            get { return base.EventDataSize + 4; }
        }

        protected override void WriteEventData(System.IO.Stream s)
        {
            base.WriteEventData(s);
            BinaryWriter writer = new BinaryWriter(s);
            writer.Write(_itemId);
        }

        protected internal override void DeserializeObject(BinaryReader reader)
        {
            base.DeserializeObject(reader);
            _itemId = reader.ReadUInt32();
        }

        protected internal override void SerializeObject(BinaryWriter writer)
        {
            base.SerializeObject(writer);
            writer.Write(_itemId);
        }
    }
}
